<?php 
/****
布尔教育 高端PHP培训
培  训: http://www.itbool.com
论  坛: http://www.zixue.it
****/
require('./lib/init.php');


//查询所有栏目
$sql = "select catname,cat_id from cat";
$cats = mGetAll($sql);


//判断地址栏是否有cat_id
//$cat_id = isset($_GET['cat_id']) ? $_GET['cat_id'] : '' ;
if(isset($_GET['cat_id'])) {
	$where = " and art.cat_id=$_GET[cat_id]";
}else {
	$where = '';
}


//分页代码
$sql = "select count(*) from art where 1" . $where;//获取总的文章数
$num = mGetOne($sql);//总的文章数
//getPage
$curr = isset($_GET['page']) ? $_GET['page'] : 1;//当前页码数
$cnt = 2;//每页显示条数
$page = getPage($num , $curr , $cnt);
//print_r($page);exit();


//查询所有文章
$sql = "select art_id,title,content,pubtime,comm,catname,thumb from art inner join cat on art.cat_id=cat.cat_id where 1" . $where . ' order by art_id desc limit ' . ($curr-1)*$cnt . ',' . $cnt;//.'order by art_id desc limit ' . ($curr-1)*$cnt . ',' . $cnt
//echo $sql; exit();
$arts = mGetAll($sql);
//print_r($arts);


//如果当前栏目下没有文章，跳转到首页去


require(ROOT .'/view/front/index.html');


?>